# -*- coding: utf-8 -*-
from django.http import Http404
try:
    from functools import wraps
except ImportError:
    from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.

def superuser_or_404(view_func):
    """
    Decorator for views that checks that the user is superuser
    """
    def _is_superuser(request, *args, **kwargs):
        if request.user.is_authenticated() and request.user.is_superuser:
            # The user is superuser
            return view_func(request, *args, **kwargs)
        raise Http404
    return wraps(view_func)(_is_superuser)
